package br.com.webcrm.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.webcrm.dao.MotivoDAO;
import br.com.webcrm.model.Motivo;

@Repository(value = "motivoDao")
public class MotivoDAOImpl extends BaseDAOImpl<Motivo, Integer> implements MotivoDAO {

	@Autowired
	public MotivoDAOImpl(
			@Qualifier("sessionFactory") SessionFactory factory) {
		super.setSessionFactory(factory);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public List<Motivo> consultarTodos() throws Exception {
		return consultarPorNamedQuery("Motivo.findAll");
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public Motivo consultarMotivoPorIdMotivo(Integer idMotivo) throws Exception {
		String[] nomes = {"idMotivo"};
		Object[] valores = {idMotivo};
		return this.consultarObjeto("Motivo.findByIdMotivo", nomes, valores);
		
	}

}
